﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using Telerik.WinControls.UI;
using Bitis_KeToanThue_Pro_Update.AccessDatabase;
using Bitis_KeToanThue_Pro_DungChung.Common;
using Telerik.WinControls.Primitives;
using Telerik.WinControls.Layouts;
using Telerik.WinControls.Enumerations;
using Telerik.WinControls.Data;
using Bitis_KeToanThue_Pro_Update.Common;

namespace Bitis_KeToanThue_Pro_Update.Form
{
    public partial class frmManHinhChinh : Telerik.WinControls.UI.RadForm
    {
        WellCome wc = new WellCome();
        public frmManHinhChinh()
        {
            InitializeComponent();
            khoitaolistview();
        }
        private void loaddulieu()
        {
            this.radListView1.DataSource = wc.loadgird();
            this.radListView1.DisplayMember = "TenChuongTrinh";
            this.radListView1.ValueMember = "MaChuongTrinh";
            this.radListView1.GroupDescriptors.Clear();
            this.radListView1.GroupDescriptors.Add(new GroupDescriptor(
                  new SortDescriptor[] { new SortDescriptor("Nhom", ListSortDirection.Ascending) }));



        }
        private void khoitaolistview()
        {
            this.radListView1.EnableGrouping = true;
            this.radListView1.ShowGroups = true;
            this.radListView1.ViewType = ListViewType.IconsView;
            this.radListView1.ItemSize = new Size(340, 35);
            this.radListView1.GroupItemSize = new Size(675, 40);
            this.radListView1.ItemSpacing = 3;
            this.radListView1.GroupIndent = 0;
            this.radListView1.HorizontalScrollState = ScrollState.AlwaysHide;
            this.radListView1.EnableKineticScrolling = true;
            this.radListView1.VerticalScrollState = ScrollState.AlwaysHide;
            this.radListView1.FullRowSelect = false;
            this.radListView1.AllowEdit = false;
            this.radListView1.AllowRemove = false;
            this.radListView1.ListViewElement.ViewElement.ViewElement.Margin = new Padding(7, 10, 2, 10);
            this.radListView1.ListViewElement.ViewElement.Orientation = Orientation.Vertical;

        }

        private void frmManHinhChinh_Load(object sender, EventArgs e)
        {
            loaddulieu();
        }

        private void radListView1_ItemMouseClick(object sender, ListViewItemEventArgs e)
        {
            BienHeThong.ht_machuongtrinh = ClassXuLyChung.GetSafeInt(e.Item.Value);
            BienHeThong.ht_tenchuongtrinh = e.Item.Text;
            if (BienHeThong.ht_machuongtrinh != 0)
            {
                ShowFormMenuMainProject.openformcloseformfinal("Bitis_KeToanThue_Pro_Update.Form.frmLogin", "frmLogin", this);
            }
        }

        private void radListView1_VisualItemFormatting(object sender, ListViewVisualItemEventArgs e)
        {
            if (e.VisualItem is BaseListViewGroupVisualItem)
            {

                return;
            }

            if (this.radListView1.ViewType == ListViewType.IconsView)
            {
                /* if (e.VisualItem.Selected)
                 {
                     e.VisualItem.BorderLeftWidth = 0;
                     e.VisualItem.BorderRightWidth = 0;
                     e.VisualItem.BorderTopWidth = 0;
                     e.VisualItem.BorderBottomWidth = 0;
                     //e.VisualItem.BorderBoxStyle=BorderBoxStyle.
                 }*/


                e.VisualItem.Text = "<html>" +
                   "<span style=\"color:#808AEE;\"> " + "  " + e.VisualItem.Data["TenChuongTrinh"] + "</span>";

                e.VisualItem.ImageLayout = ImageLayout.Stretch;
                e.VisualItem.ImageAlignment = ContentAlignment.MiddleLeft;

                //    e.VisualItem.ForeColor = Color.Navy;
                // e.VisualItem.Layout.Padding = new Padding(10,0,5,0);
                e.VisualItem.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(163)));
            }
        }

        private void radListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            DataRowView rowView = (DataRowView)e.Item.DataBoundItem;
            string photo = ClassXuLyChung.GetSafeString(rowView["Icon"]);
            if (!string.IsNullOrEmpty(photo))
            {
                e.Item.Image = ClassXuLyChung.ConvertByeToImage((byte[])rowView["Icon"]);
            }
            else
            {
                e.Item.Image = null;
            }
        }
    }
}
